#include <cstddef>
#include <iostream>
#include <iterator>
#include <map>
#include <string>
#include <vector>

std::string OTK = "([{<";
std::string ALL = "({[<>]})";

int main() {
  std::map<char, int> slovar;
  slovar['('] = 1;
  slovar[')'] = 1;
  slovar['['] = 2;
  slovar[']'] = 2;
  slovar['{'] = 3;
  slovar['}'] = 3;
  slovar['<'] = 4;
  slovar['>'] = 4;
  std::string stroka;
  std::cin >> stroka;
  int flag = 1;
  std::vector<int> stek; // создаем стек
  for (size_t i = 0; i < stroka.size(); i++) {
    if (ALL.find(stroka[i]) != std::string::npos) {

      if (OTK.find(stroka[i]) != std::string::npos) {
        stek.push_back(slovar[stroka[i]]);
      } else {
        if (stek.back() == slovar[stroka[i]]) {
          stek.pop_back();
        } else {
          flag = 0;
        }
      }
    }
  }
    if (stek.size() == 0 && flag == 1){
        std::cout << "True" << std::endl;
    }
    else{
        std::cout << "False" << std::endl;
    }
  return 0;
}